/** @format */

import { createApp } from 'vue'
import JsxDialog from './Index.vue'

export const onOpenUseTsxByCompDialog = (props: any) => {
  const theDiv = document.createElement('div')
  document.body.appendChild(theDiv)
  let theDialogProps = {}
  function onRender(props: any) {
    theDialogProps = props
    return createApp({
      data() {
        return { theDialogProps, vIf: true }
      },
      render() {
        // 先解构，避免报错，原因不详
        const cdProps = { ...this.theDialogProps }
        return this.vIf ? <JsxDialog {...cdProps} /> : null
      },
    }).mount(theDiv)
  }
  return onRender(props)
}

// import { createApp } from 'vue';
// import JsxDialog from './jsx-dialog.vue';
// export const onOpenDialog = (props: any) => {
//     const theDiv = document.createElement('div');
//     document.body.appendChild(theDiv);
//     return createApp(JsxDialog, props).mount(theDiv);
// };
